<template>
  <div class="temp-dec">
    <div class="title">{{ title }}</div>
    <div class="box">
      <div class="val">
        <strong>{{ val }}</strong>
        <span>{{ unit }}</span>
      </div>
      <div class="bg">
        <img src="./img/heat-blue.png" class="temp"/>
        <div class="process">
          <div class="bg-line" :style="{ 'height': kd }"></div>
          <div class="mark-line" :style="{ bottom: kd }"></div>
        </div>
        <div class="kd">
          <span>1000</span>
          <span>500</span>
          <span>100</span>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
  export default {
    name: 'temp01',
    data () {
      return {
        val: 320
      };
    },
    props: {
      title: {
        default: '温度变化'
      },
      max: {
        default: 1000 // 最大量程
      },
      min: {
        default: 0 // 最小量程
      },
      unit: {
        default: 'hPa'
      }
    },
    computed: {
      // 高度94， 总共15格计算出每一个格子px
      kd () {
        return `${(this.val / (this.max - this.min)) * 100}%`;
      }
    },
    methods: {
    }
  };
</script>
<style lang="scss" scoped>
  .temp-dec {
    width: 130px;
    height: 130px;
    padding: 5px;
    background: #102c58;
    .title {
      color: #ccc;
      text-align: left;
    }
    .kd {
      span {
        position: absolute;
        left: 40px;
        top: 0;
        font-size: 12px;
        color: #ccc;
      }
      span:nth-child(2) {
        top: 22px;
      }
      span:nth-child(3) {
        top: 45px;
      }
    }
    .box {
      display: flex;
      // justify-content: space-between;
      .bg {
        position: relative;
        .temp {
          width: 56px;
        }
        .mark-line {
          position: absolute;
          left: -7px;
          width: 10px;
          height: 3px;
          background: #b02323;
        }
        .process {
          position: absolute;
          left: 8px;
          bottom: 28px;
          width: 12px;
          height: 55px;
          border-top-right-radius: 50px;
          border-top-left-radius: 50px;
        }
        .bg-line {
          position: absolute;
          width: 12px;
          height: 55px;
          bottom: 0;
          background: #4d719b;
          border-top-right-radius: 50px;
          border-top-left-radius: 50px;
        }
      }
      .val {
        color: #ccc;
        padding: 20px 0 0 0;
        margin-right: 15px;
        strong {
          display: block;
          font-size: 22px;
          color: #fff;
        }
        span {
          color: #ccc;
        }
      }
    }
  }
</style>